<?
include("../lib/config.php");
$nik 	= $HTTP_GET_VARS['nik'];
$op		= $HTTP_GET_VARS['op'];
$no		= $HTTP_GET_VARS['no'];

if($op == "edit"){
	$Faction = "../lib/update.php";
	$Vbutton = "Update";
	$query	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, *, CONVERT(CHAR(12), Dari, 103) tgl_dari, CONVERT(CHAR(12), Sampai, 103) tgl_sampai, CONVERT(CHAR(12), TglSertifikat, 103) tgl_sertifikat, CONVERT(CHAR(12), MasaSertifikat, 103) masa_sertifikat, CONVERT(CHAR(12), AwalIkatan, 103) awal_ikatan, CONVERT(CHAR(12), AkhirIkatan, 103) akhir_ikatan FROM KURSUS WHERE NIK='$nik') SELECT * FROM limit Where No='$no' ",$conn);
	$row	= mssql_fetch_array($query);
}
else{
	$Faction = "../lib/save.php";
	$Vbutton = "Simpan";
}

include("../header.php");
?>
<script type="text/javascript">
	function LoadFocus(){
		document.forms[0].elements[0].focus();
	}
	
	MaskInput = function(f, m){
	function mask(e){
		var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
			rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
		function accept(c, rule){
			for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
				if(r & i && patterns[i].test(c))
					break;
				return i <= r || c == rule;
		}
		var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
		(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
			r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
			: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
			r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
	}
	for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
		addEvent(f, i, mask);
};

	function Validate(){
		
		if(document.forms[0].nik.value == ""){
			alert("Field: NIK tidak boleh kosong ...");
			document.forms[0].nik.focus();
			return false;
		}
		
		/*
		if(document.forms[0].seq_no.value == ""){
			alert("Field: Seq. No. tidak boleh kosong ...");
			document.forms[0].seq_no.focus();
			return false;
		}
		*/
		
		if(document.forms[0].program.value == ""){
			alert("Field: Program tidak boleh kosong ...");
			document.forms[0].program.focus();
			return false;
		}
		
		if(document.forms[0].penyelenggara.value == ""){
			alert("Field: Penyelenggara tidak boleh kosong ...");
			document.forms[0].penyelenggara.focus();
			return false;
		}

		if(document.forms[0].tempat.value == ""){
			alert("Field: Tempat tidak boleh kosong ...");
			document.forms[0].tempat.focus();
			return false;
		}
/*
		if(document.forms[0].lama.value == ""){
			alert("Field: Lama tidak boleh kosong ...");
			document.forms[0].lama.focus();
			return false;
		}

		if(document.forms[0].jam.value == ""){
			alert("Field: Jam tidak boleh kosong ...");
			document.forms[0].jam.focus();
			return false;
		}
*/
		if(document.forms[0].dari.value == ""){
			alert("Field: Dari tidak boleh kosong ...");
			document.forms[0].dari.focus();
			return false;
		}
		
		if(document.forms[0].sampai.value == ""){
			alert("Field: Sampai tidak boleh kosong ...");
			document.forms[0].sampai.focus();
			return false;
		}
		
		if(document.forms[0].jenis.value == ""){
			alert("Field: Jenis tidak boleh kosong ...");
			document.forms[0].jenis.focus();
			return false;
		}
/*
		if(document.forms[0].no_sertifikat.value == ""){
			alert("Field: No Sertifikat tidak boleh kosong ...");
			document.forms[0].no_sertifikat.focus();
			return false;
		}
	*/	
		if(document.forms[0].tgl_sertifikat.value == ""){
			alert("Field: Tanggal Sertifikat tidak boleh kosong ...");
			document.forms[0].tgl_sertifikat.focus();
			return false;
		}
/*
		if(document.forms[0].masa_sertifikat.value == ""){
			alert("Field: Masa Sertifikat tidak boleh kosong ...");
			document.forms[0].masa_sertifikat.focus();
			return false;
		}
	
		if(document.forms[0].keterangan.value == ""){
			alert("Field: Keterangan tidak boleh kosong ...");
			document.forms[0].keterangan.focus();
			return false;
		}

		if(document.forms[0].profesi.value == ""){
			alert("Field: Profesi tidak boleh kosong ...");
			document.forms[0].profesi.focus();
			return false;
		}

		if(document.forms[0].sertifikat.value == ""){
			alert("Field: Sertifikat tidak boleh kosong ...");
			document.forms[0].sertifikat.focus();
			return false;
		}
		
		if(document.forms[0].brevet.value == ""){
			alert("Field: Brevet tidak boleh kosong ...");
			document.forms[0].brevet.focus();
			return false;
		}

		if(document.forms[0].intern.value == ""){
			alert("Field: Intern tidak boleh kosong ...");
			document.forms[0].intern.focus();
			return false;
		}
		
		if(document.forms[0].bea_training.value == ""){
			alert("Field: Biaya Training tidak boleh kosong ...");
			document.forms[0].bea_training.focus();
			return false;
		}
		
		if(document.forms[0].bea_akomodasi.value == ""){
			alert("Field: Biaya Akomodasi tidak boleh kosong ...");
			document.forms[0].bea_akomodasi.focus();
			return false;
		}
		
		if(document.forms[0].bea_transport.value == ""){
			alert("Field: Biaya Transportasi tidak boleh kosong ...");
			document.forms[0].bea_transport.focus();
			return false;
		}

		if(document.forms[0].bea_lain.value == ""){
			alert("Field: Biaya Lain tidak boleh kosong ...");
			document.forms[0].bea_lain.focus();
			return false;
		}
		/*
		if(document.forms[0].ikatan_dinas.value == ""){
			alert("Field: Ikatan Dinas tidak boleh kosong ...");
			document.forms[0].ikatan_dinas.focus();
			return false;
		}
		
		if(document.forms[0].awal_ikatan.value == ""){
			alert("Field: Awal Ikatan Dinas tidak boleh kosong ...");
			document.forms[0].awal_ikatan.focus();
			return false;
		}
		
		if(document.forms[0].akhir_ikatan.value == ""){
			alert("Field: Akhir Ikatan Dinas tidak boleh kosong ...");
			document.forms[0].akhir_ikatan.focus();
			return false;
		}

		if(document.forms[0].laporan.value == ""){
			alert("Field: Laporan Dinas tidak boleh kosong ...");
			document.forms[0].laporan.focus();
			return false;
		}
*/
		document.forms[0].submit();
	
	}
</script>
</head>
<form name="FEmployee" method="post" action="<?=$Faction?>">
<table width="100%">
 <tr>
  <td colspan="2">
	<table width="100%">
	<tr>
	 <td colspan="2" class="line_bottom">&nbsp;&nbsp;<b>Data Pendidikan Non Formal/Kursus/Training</b></td>
	</tr>
	<tr>
	 <tr>
	  <td>&nbsp;</td>
	 <td align="right" class="line_bottom">
	 <a href="../lib/detailemp.php?show=pribadi&amp;nik=<?=$nik?>">Data Pribadi</a> &raquo; 
	 <a href="../lib/detailemp.php?show=data_umum&amp;nik=<?=$nik?>">Data Umum</a> &raquo; 
	 <a href="../lib/detailemp.php?show=pendidikan&amp;nik=<?=$nik?>"><b>Pendidikan</b></a> &raquo; 
	 <a href="../lib/detailemp.php?show=kecakapan&amp;nik=<?=$nik?>">Kecakapan</a> &raquo; 
	 <a href="../lib/detailemp.php?show=keluarga&amp;nik=<?=$nik?>">Keluarga</a> &raquo; 
	 <a href="../lib/detailemp.php?show=karir&amp;nik=<?=$nik?>">Pengalaman</a> &raquo; 
	 <a href="../lib/detailemp.php?show=organisasi&amp;nik=<?=$nik?>">Organisasi</a> 
	 </td>
	 </tr>
	</table>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <tr>
 <td>
 <table>
 <tr>
  <td><b>NIK</b></td>
  <td>: <input type="text" maxlength="10" readonly="" value="<?=$nik?>" style="font-weight:bold;"  class="text" name="nik"/> <span class="required">*</span></td>
 </tr>
 <!--<tr>
  <td>Seq No.</td>
  <td>: <input type="text" maxlength="10" value=""  class="text" name="seq_no"/> <span class="required">*</span></td>
 </tr>-->
 <tr>
  <td>Program</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[Program]?>"   size="35" class="text" name="program"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Penyelenggara</td>
  <td>: <input type="text" maxlength="30" value="<?=$row[Penyelenggara]?>"   size="35" class="text" name="penyelenggara"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Tempat</td>
  <td>: <input type="text" maxlength="30" value="<?=$row[Tempat]?>"   size="35" class="text" name="tempat"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Lama</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[Lama]?>"   size="11" class="text" name="lama"/></td>
 </tr>
 <tr>
  <td>Jam</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[Jam]?>"   size="11" class="text" name="jam"/></td>
 </tr>
 <tr>
  <td>Dari (Mulai)</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[tgl_dari]?>"   size="11" class="text" name="dari"/> <span class="required">*</span> <a href="javascript:calA.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
 </tr>
 <tr>
  <td>Sampai (Selesai)</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[tgl_sampai]?>"   size="11" class="text" name="sampai"/> <span class="required">*</span> <a href="javascript:calB.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
 </tr>
 <tr>
  <td>Jenis</td>
  <td>: 
  <!--<input type="text" maxlength="10" value=""   size="15" class="text" name="jenis"/> -->
  <select name="jenis"/>
  <?
  	$sjenis	= mssql_query("SELECT * FROM VKursus Where kode='".$row[Jenis]."'",$conn);
	$rjenis = mssql_fetch_array($sjenis);
  	echo'<option value="'.$rjenis[kode].'">'.$rjenis[nama].'</option>';
	//echo"<input type='text' value='$rjenis[kode]'>";
  ?>
  <option value="">-Select-</option>
   <? 
   		$sPrj	= mssql_query("SELECT * FROM VKursus ",$conn);
		while($rPrj = mssql_fetch_array($sPrj)){
			echo"<option value='".$rPrj[kode]."'>$rPrj[nama]</option>";
		}
   ?>
  </select> 
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>No. Sertifikat</td>
  <td>: <input type="text" maxlength="25" value="<?=$row[NoSertifikat]?>"   size="20" class="text" name="no_sertifikat"/></td>
 </tr>
 <tr>
  <td>Tgl Sertifikat</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[tgl_sertifikat]?>"   size="11" class="text" name="tgl_sertifikat"/> <span class="required">*</span> <a href="javascript:cal.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a> </td>
 </tr>
 <tr>
  <td>Masa Sertifikat</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[masa_sertifikat]?>"   size="11" class="text" name="masa_sertifikat"/> <a href="javascript:calC.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
 </tr>
 <tr>
  <td valign="top">Keterangan</td>
  <td valign="top">&nbsp;  <textarea name="keterangan" rows="5" cols="35"><?=$row[Keterangan]?></textarea></td>
 </tr>
<!--
 <tr>
  <td>Profesi</td>
  <td>: 
  <select name="profesi"/>
  <?
//  	$sprof	= mssql_query("SELECT * FROM VKursus Where kode='".$row[Profesi]."'",$conn);
//	$rprof = mssql_fetch_array($sprof);
//  	echo'<option value="'.$rprof[kode].'">'.$rprof[nama].'</option>';
  ?>
  <option value="">-Select-</option>
   <? 
  // 		$sPr	= mssql_query("SELECT * FROM VKursus ",$conn);
//		while($rPr = mssql_fetch_array($sPr)){
//			echo"<option value='".$rPr[kode]."'>$rPr[nama]</option>";
//		}
   ?>
  </select> 
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Sertifikat</td>
  <td>: 
  <select name="sertifikat"/>
  <?
  //	$sser	= mssql_query("SELECT * FROM VKursus Where kode='".$row[Sertifikat]."'",$conn);
//	$rser 	= mssql_fetch_array($sser);
 // 	echo'<option value="'.$rser[kode].'">'.$rser[nama].'</option>';
  ?>
  <option value="">-Select-</option>
   <? 
   //		$sPr	= mssql_query("SELECT * FROM VKursus ",$conn);
//		while($rPr = mssql_fetch_array($sPr)){
//			echo"<option value='".$rPr[kode]."'>$rPr[nama]</option>";
//		}
   ?>
  </select> 
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Brevet</td>
  <td>: 
  <select name="brevet"/>
  <?
  //	$sbrev	= mssql_query("SELECT * FROM VKursus Where kode='".$row[Brevet]."'",$conn);
	//$rbrev 	= mssql_fetch_array($sbrev);
  	//echo'<option value="'.$rbrev[kode].'">'.$rbrev[nama].'</option>';
  ?>
  <option value="">-Select-</option>
   <? 
   //		$sPr	= mssql_query("SELECT * FROM VKursus ",$conn);
//		while($rPr = mssql_fetch_array($sPr)){
//			echo"<option value='".$rPr[kode]."'>$rPr[nama]</option>";
//		}
   ?>
  </select> 
  <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Intern</td>
  <td>: 
  <select name="intern"/>
  <?
  //	$sintern	= mssql_query("SELECT * FROM VKursus Where kode='".$row[Intern]."'",$conn);
//	$rintern 	= mssql_fetch_array($sintern);
  	//echo'<option value="'.$rintern[kode].'">'.$rintern[nama].'</option>';
  ?>
  <option value="">-Select-</option>
   <? 
   		//$sPr	= mssql_query("SELECT * FROM VKursus ",$conn);
		//while($rPr = mssql_fetch_array($sPr)){
		//	echo"<option value='".$rPr[kode]."'>$rPr[nama]</option>";
		//}
   ?>
  </select> 
  <span class="required">*</span></td>
 </tr>
 -->
 <tr>
  <td colspan="2"><hr noshade="noshade" size="-2" color="#666666" /></td>
 </tr>
 <tr>
  <td>Biaya Training</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[BiayaTraining]?>"   size="25" class="text" name="bea_training"/></td>
 </tr>
 <tr>
  <td>Biaya Akomodasi</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[BiayaAkomodasi]?>"   size="25" class="text" name="bea_akomodasi"/></td>
 </tr>
 <tr>
  <td>Biaya Transportasi</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[BiayaTransport]?>"   size="25" class="text" name="bea_transport"/></td>
 </tr>
 <tr>
  <td>Biaya Lain</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[BiayaLain]?>"   size="25" class="text" name="bea_lain"/></td>
 </tr>
 <tr>
  <td>Ikatan Dinas</td>
  <td>: 
  <!--
  <input type="text" maxlength="10" value=""   size="20" class="text" name="ikatan_dinas"/> -->
  <select name="ikatan_dinas">
  <?
	if($row[IkatanDinas] == "1"){
   		echo'<option value="1">Ya</option>';
	}
	elseif($row[IkatanDinas] == "0"){
   		echo'<option value="0">Tidak</option>';
	}
  ?>
   <option value="">-Select-</option>
   <option value="1">Ya</option>
   <option value="0">Tidak</option>
  </select>
   <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Awal Ikatan</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[awal_ikatan]?>"   size="10" class="text" name="awal_ikatan"/> <a href="javascript:calD.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
 </tr>
 <tr>
  <td>Akhir Ikatan</td>
  <td>: <input type="text" maxlength="10" value="<?=$row[akhir_ikatan]?>"   size="10" class="text" name="akhir_ikatan"/> <a href="javascript:calE.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
 </tr>
 <tr>
  <td>Laporan</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[Laporan]?>"   size="50" class="text" name="laporan"/> </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td align="left"><br /><br />
  <input type="hidden" name="cat" value="kursus" />
  <input type="hidden" name="no" value="<?=$row[No]?>" />
  <input type="button" value="Batal" class="button" onclick="Javascript:history.back();"/><input type="button" value="<?=$Vbutton?>" class="button" onClick="Validate();" />
  <br /><br />
  </td>
 </tr>
</table>
</form>
</td>
</tr>
<tr>
 <td colspan="2" style="border:none;"><? include("../footer.php"); ?></td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[

var f = document.forms[0];
/*MaskInput(f.elements[0], "(99)9999-9999");
MaskInput(f.elements[1], "99/99/9999");
MaskInput(f.elements[2], "Cc99-*C");
MaskInput(f.elements[3], "E^abc");
MaskInput(f.elements[4], "O^abc");
MaskInput(f.elements[5], "C^");
MaskInput(f.elements[6], "C^ ");
MaskInput(f.elements[7], "9^abc");
*/
MaskInput(f.tgl_sertifikat,"99/99/9999");
MaskInput(f.dari,"99/99/9999");
MaskInput(f.sampai,"99/99/9999");
MaskInput(f.awal_ikatan,"99/99/9999");
MaskInput(f.akhir_ikatan,"99/99/9999");
//MaskInput(f.masa_sertifikat,"99/99/9999");
MaskInput(f.bea_training,"999999999999");
MaskInput(f.bea_akomodasi,"999999999999");
MaskInput(f.bea_transport,"999999999999");
MaskInput(f.bea_lain,"999999999999");
//MaskInput(f.jam,"99");

//]]>
</script>
<script type="text/javascript">
// script untuk popup calendar
	var cal = new calendar1(document.forms['FEmployee'].elements['tgl_sertifikat']);
	cal.year_scroll = true;
	cal.time_comp = false;
	
	var calA = new calendar1(document.forms['FEmployee'].elements['dari']);
	calA.year_scroll = true;
	calA.time_comp = false;

	var calB = new calendar1(document.forms['FEmployee'].elements['sampai']);
	calB.year_scroll = true;
	calB.time_comp = false;

	var calC = new calendar1(document.forms['FEmployee'].elements['masa_sertifikat']);
	calC.year_scroll = true;
	calC.time_comp = false;

	var calD = new calendar1(document.forms['FEmployee'].elements['awal_ikatan']);
	calD.year_scroll = true;
	calD.time_comp = false;

	var calE = new calendar1(document.forms['FEmployee'].elements['akhir_ikatan']);
	calE.year_scroll = true;
	calE.time_comp = false;

</script>
<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
